package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.SaleClientBean;
import com.project.dao.ISaleClientDao;
import com.project.service.ISaleClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.util.List;

/**
 * @author lyl
 * description:
 */
@Service
@Transactional
public class SaleClientServiceImpl implements ISaleClientService {
    @Autowired
    private ISaleClientDao saleClientDao;

    @Override
    public List<SaleClientBean> showAll() {
        return saleClientDao.findByPage(null, null, null);
    }

    @Override
    public PageInfo<SaleClientBean> findByPage(int pageNum, String clientName, LocalDate startDate, LocalDate endDate) {
        PageHelper.startPage(pageNum, 3);
        PageInfo<SaleClientBean> info = PageInfo.of(saleClientDao.findByPage(clientName, startDate, endDate));
        return info;
    }
}
